#include<stdio.h>
#include<string.h>
#define USER "admin"
#define PASSWORD "123456"

int main()
{
	char user[20] = {0};
	char psw[20] = {0};
	int isUserRight = 0;  //用户名是否验证通过
	const int maxCount = 5;    //密码最多允许验证的次数
	int count = 0;
	while(1){
		//用户名的逻辑	
		if(count==0){	
			printf("用户名:\n");
			gets(user);
			if(strcmp(user,USER)!=0){
				printf("用户名不正确，请重新输入！");
				continue;
			}
		}

		//密码的逻辑
		count++;
		printf("密码:\n");
		gets(psw);

		if(strcmp(psw,PASSWORD)==0){
			printf("恭喜您%s,登录成功!\n",USER);
			break;
		}else{
			if(count < maxCount){
				printf("密码不正确,请重新输入!\n");
				continue;
			}else{
				printf("重复输入超过%d次,请稍后再试!\n", maxCount);
				break;
			}
		}
	}

	return 0;
}
